package com.javacoo.junit.generator.config;

import java.util.ArrayList;
import java.util.List;

import static com.javacoo.junit.generator.internal.util.StringUtility.stringHasValue;
import static com.javacoo.junit.generator.internal.util.messages.Messages.getString;
/**
 * 上下文对象
 * <li></li>
 *
 * @author: duanyong@jccfc.com
 * @since: 2020/12/31 13:45
 */
public class Context extends PropertyHolder{
    /**
     * id
     */
    private String id;
    /**
     * 模板配置
     */
    private TemplateConfiguration templateConfiguration;
    /**
     * 类配置
     */
    private List<ClassConfiguration> classConfigurations;

    public Context() {
        classConfigurations = new ArrayList<>();
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public TemplateConfiguration getTemplateConfiguration() {
        return templateConfiguration;
    }

    public void setTemplateConfiguration(TemplateConfiguration templateConfiguration) {
        this.templateConfiguration = templateConfiguration;
    }

    public List<ClassConfiguration> getClassConfigurations() {
        return classConfigurations;
    }

    public void setClassConfigurations(List<ClassConfiguration> classConfigurations) {
        this.classConfigurations = classConfigurations;
    }

    /**
     * 校验
     * <li>这个方法做了一个简单的验证，它确保所有必需的字段都已填写。它不行任何更复杂的操作，如验证数据库表是否存在或验证命名列是否存在</li>
     * @author duanyong@jccfc.com
     * @date 2020/12/31 16:32
     * @param errors: 异常信息
     */
    public void validate(List<String> errors) {
        if (!stringHasValue(id)) {
            errors.add(getString("ValidationError.16"));
        }
        // TODO

    }
}
